import { EChartOption } from "echarts";



function Pie() {
    let dataArr = [];
    for (var i = 0; i < 100; i++) {
        if (i % 10 === 0) {
            dataArr.push({
                name: (i + 1).toString(),
                value: 30,
                itemStyle: {
                    normal: {
                        color: "rgba(0,255,255,1)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)",
                    }
                }
            })
        } else {
            dataArr.push({
                name: (i + 1).toString(),
                value: 100,
                itemStyle: {
                    normal: {
                        color: "rgba(0,0,0,0)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        }
    }
    return dataArr
}

function Pie1() {
    let dataArr = [];
    for (var i = 0; i < 100; i++) {
        if (i % 5 === 0) {
            dataArr.push({
                name: (i + 1).toString(),
                value: 20,
                itemStyle: {
                    normal: {
                        color: "rgba(0,255,255,1)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        } else {
            dataArr.push({
                name: (i + 1).toString(),
                value: 100,
                itemStyle: {
                    normal: {
                        color: "rgba(0,0,0,0)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        }
    }
    return dataArr
}

function Pie2() {
    let dataArr = [];
    for (var i = 0; i < 100; i++) {
        if (i % 5 === 0) {
            dataArr.push({
                name: (i + 1).toString(),
                value: 20,
                itemStyle: {
                    normal: {
                        color: "rgba(0,255,255,.3)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        } else {
            dataArr.push({
                name: (i + 1).toString(),
                value: 100,
                itemStyle: {
                    normal: {
                        color: "rgba(0,0,0,0)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        }
    }
    return dataArr
}

function Pie3() {
    let dataArr = [];
    for (var i = 0; i < 100; i++) {
        if (i % 10 === 0) {
            dataArr.push({
                name: (i + 1).toString(),
                value: 30,
                itemStyle: {
                    normal: {
                        color: "rgba(0,255,255,.5)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        } else {
            dataArr.push({
                name: (i + 1).toString(),
                value: 100,
                itemStyle: {
                    normal: {
                        color: "rgba(0,0,0,0)",
                        borderWidth: 0,
                        borderColor: "rgba(0,0,0,0)"
                    }
                }
            })
        }
    }
    return dataArr
}


export function pieoption(data: { value: number, name: string }): EChartOption {

    return {
        title: [{
            text: data.value,
            x: '48%',
            y: '39%',
            textAlign: 'center',
            textStyle: {
                fontSize: '20',
                color: '#0FF',
                textAlign: 'center',
            },
        }, {
            text: data.name,
            left: '48%',
            top: '52%',
            textAlign: 'center',
            textStyle: {
                fontSize: '15',
                color: 'white',
                textAlign: 'center',
            },
        }],
        series: [{
            type: 'pie',
            radius: ['56%', '60%'],
            center: ['50%', '50%'],
            data: [{
                value: 100,
                itemStyle: {
                    color: {
                        colorStops: [{
                            offset: 0,
                            color: '#A098FC' // 0% 处的颜色
                        },
                        {
                            offset: 0.3,
                            color: '#4386FA' // 0% 处的颜色
                        },
                        {
                            offset: 0.6,
                            color: '#4FADFD' // 0% 处的颜色
                        },
                        {
                            offset: 0.8,
                            color: '#0CD3DB' // 100% 处的颜色
                        }, {
                            offset: 1,
                            color: '#646CF9' // 100% 处的颜色
                        }
                        ]
                    },
                },
                label: {
                    show: false
                },
                labelLine: {
                    normal: {
                        smooth: true,
                        lineStyle: {
                            width: 0
                        }
                    }
                },
                hoverAnimation: false,
            },]
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            radius: ['87%', '85.5%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie()
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            startAngle: -150,
            radius: ['85%', '83.5%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie3()
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            startAngle: -140,
            radius: ['78%', '76.5%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie()
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            radius: ['71%', '70%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie1()
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            startAngle: -140,
            radius: ['81%', '80%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie2()
        },
        {
            type: 'pie',
            zlevel: 0,
            silent: true,
            startAngle: -147.5,
            radius: ['81%', '80%'],
            z: 1,
            label: {
                normal: {
                    show: false
                },
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: Pie2()
        },

        ]
    } as unknown as EChartOption;
}
